local skynet = require "skynet"
local env = require "env"

local MYSQL_PER_CONN = env.MYSQL_PER_CONN
local idx = 0

return setmetatable({}, {
    __index = function(t, k)
        idx = idx + 1
        if idx > MYSQL_PER_CONN then
            idx = 1
        end
        return function(...)
            return skynet.call("MYSQL"..idx, "lua", k, ...)
        end
    end,
    __newindex = function()
        error("cannot write key")
    end,
})
